﻿using MediatR;
using SheepStorage.API.Application.Command.AreaCommand;
using SheepStorage.API.Application.Command.PlaceCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.PlaceHandlers
{
    public class PlaceListCommandHandlers : IRequestHandler<PlaceListCommand, Results<List<Place>>>
    {

        private readonly IPlaceService _placeService;

        public PlaceListCommandHandlers(IPlaceService placeService)
        {
            _placeService = placeService;
        }
        /// <summary>
        /// 显示地方
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
       public async Task<Results<List<Place>>> Handle(PlaceListCommand request, CancellationToken cancellationToken)
        {
            return Results<List<Place>>.DataResult(await _placeService.GetPlace(request.AreaId));
        }
    }
}
